package com.example.campus;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.BitmapFactory;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;

public class NavigationAdapter extends BaseAdapter {
	ArrayList<ItemInfo> list;
	Context context;

	public NavigationAdapter(Context context, ArrayList<ItemInfo> list) {
		this.list = list;
		this.context = context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		LinearLayout layout=new LinearLayout(context);
		ImageView img=new ImageView(context);
		TextView text=new TextView(context);
		layout.addView(img);
		layout.addView(text);
		LinearLayout.LayoutParams imgp=new LinearLayout.LayoutParams(100,100);
		img.setLayoutParams(imgp);
		img.setImageBitmap(BitmapFactory.decodeResource(context.getResources(), list.get(position).iconid));
		text.setText(list.get(position).name);
		text.setOnClickListener(list.get(position).listener);
		return layout;
	}
}
